﻿<Window x:Class="Graphing.View.EditPointsView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ViewModel="clr-namespace:Graphing.ViewModel"
        Title="TestView" Height="200" Width="500" ResizeMode="NoResize">
    <Window.Resources>
        <ViewModel:EditPointsViewModel x:Key="EditPointsViewModel" />
        
        <!-- Validation Error Template(used to display the error message on the bottom of the boxes) -->
        <ControlTemplate x:Key="validationTemplate">
            <DockPanel LastChildFill="True">
                <TextBlock DockPanel.Dock="Bottom" 
                            Foreground="Red"
                            FontSize="12"
                            Text="{Binding ElementName=MyAdorner, 
                                    Path=AdornedElement.(Validation.Errors).CurrentItem.ErrorContent}"
                                    >
                </TextBlock>
                <Border BorderBrush="Red" BorderThickness="1" MinWidth="82" MinHeight="25">
                    <AdornedElementPlaceholder Name="MyAdorner" MinWidth="82" MinHeight="25" />
                </Border>
            </DockPanel>
        </ControlTemplate>
    </Window.Resources>
    <Grid DataContext="{StaticResource EditPointsViewModel}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="65*" />
            <ColumnDefinition Width="20*" />
            <ColumnDefinition Width="145*" />
            <ColumnDefinition Width="20*" />
            <ColumnDefinition Width="145*" />
            <ColumnDefinition Width="20*" />
            <ColumnDefinition Width="145*" />
            <ColumnDefinition Width="25" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="50" />
            <RowDefinition Height="25" />
            <RowDefinition Height="25" />
            <RowDefinition Height="50" />
        </Grid.RowDefinitions>

        <!-- Point Row. -->
        <!-- Point Label. -->
        <Label Content="Point" Grid.Column="0" Grid.Row="1" MinHeight="25" MinWidth="65" Name="point" Foreground="Black" />

        <!-- X Label. -->
        <Label Content="X:" Grid.Column="1" Grid.Row="1" MinHeight="25" MinWidth="35" Name="x" />

        <!-- X TextBox. -->
        <TextBox Validation.ErrorTemplate="{StaticResource validationTemplate}" Text="{Binding Path=x, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}"  
                 Grid.Column="2" Grid.Row="1" MinHeight="25" MinWidth="75" BorderThickness="2" x:Name="xEdit" />

        <!-- Y Label. -->
        <Label Content="Y:" Grid.Column="3" Grid.Row="1" MinHeight="25" MinWidth="35" Name="y" />

        <!-- Y Text Box. -->
        <TextBox Validation.ErrorTemplate="{StaticResource validationTemplate}" Text="{Binding Path=y, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" 
                 Grid.Column="4" Grid.Row="1"  MinHeight="25" MinWidth="75" BorderThickness="2" Name="yEdit" 
                 />

        <!-- Z Label. -->
        <Label Content="Z:" Grid.Column="5" Grid.Row="1" MinHeight="25" MinWidth="35" Name="z" />

        <!-- Z Text Box. -->
        <TextBox Validation.ErrorTemplate="{StaticResource validationTemplate}" Text="{Binding Path=z, ValidatesOnExceptions=True, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}"
                 Grid.Column="6" Grid.Row="1" MinHeight="25" MinWidth="75" BorderThickness="2" Name="zEdit" 
                 />
        
        <!-- Cancel Button -->
        <Button Command="{Binding Path=CancelCommand}" Content="Cancel" Grid.Column="5" Grid.Row="3" Grid.ColumnSpan="2" Height="25" Width="75" Name="cancelBtn" />
    </Grid>
</Window>
